package com.wdc.service.impl;


import com.wdc.entity.query.SimplePage;
import com.wdc.enums.PageSize;
import com.wdc.entity.vo.PaginationResultVo;
import com.wdc.entity.po.UserContactApply;
import com.wdc.entity.query.UserContactApplyQuery;
import com.wdc.mapper.UserContactApplyMappers;
import com.wdc.service.UserContactApplyService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * @author: WDC
 * @description:Service
 * @date:2024/09/19
 */
@Service("userContactApplyService")
public class UserContactApplyServiceImpl implements UserContactApplyService {


	@Resource
	private UserContactApplyMappers<UserContactApply, UserContactApplyQuery> userContactApplyMappers;

	/**
	 * 根据条件查询列表
	 */
	public List<UserContactApply> findListByParam(UserContactApplyQuery query) {
		return this.userContactApplyMappers.selectList(query);
	
	}

	/**
	 * 根据条件查询数量
	 */
	public Integer findCountByParam(UserContactApplyQuery query) {
		return this.userContactApplyMappers.selectCount(query);
	}

	/**
	 * 分页查询
	 */
	public PaginationResultVo<UserContactApply> findListByPage(UserContactApplyQuery query) {
		Integer count = this.findCountByParam(query);
		Integer pageSize = query.getPageSize() == null ? PageSize.SIZE15.getSize() : query.getPageSize();
		SimplePage page = new SimplePage(query.getPageNo(), count, pageSize);
		query.setSimplePage(page);
		List<UserContactApply> list = this.findListByParam(query);
		PaginationResultVo<UserContactApply> result = new PaginationResultVo(count, page.getPageSize(), page.getPageNo(), page.getPageTotal(), list);
		return result;
	}

	/**
	 * 新增
	 */
	public Integer add(UserContactApply bean) {
		return this.userContactApplyMappers.insert(bean);
	}

	/**
	 * 批量新增
	 */
	public Integer addBatch(List<UserContactApply> listBean) {
		if (listBean == null || listBean.isEmpty()) {
		return 0;
		}
		return this.userContactApplyMappers.insertBatch(listBean);	}

	/**
	 * 批量新增或修改
	 */
	public Integer addOrUpdateBatch(List<UserContactApply> listBean) {
		if (listBean == null || listBean.isEmpty()) {
		return 0;
		}
		return this.userContactApplyMappers.insertOrUpdateBatch(listBean);	}
	/**
	 * 根据ApplyId查询
	 */
	public UserContactApply getUserContactApplyByApplyId(Integer applyId) {
		return this.userContactApplyMappers.selectByApplyId(applyId);
	}

	/**
	 * 根据ApplyId更新
	 */
	public Integer updateUserContactApplyByApplyId(UserContactApply bean, Integer applyId) {
		return this.userContactApplyMappers.updateByApplyId(bean, applyId);
	}

	/**
	 * 根据ApplyId删除
	 */
	public Integer deleteUserContactApplyByApplyId(Integer applyId) {
		return this.userContactApplyMappers.deleteByApplyId(applyId);
	}

}